Completed
Push — master ( a31174...af3b49 )
by Antonio
10s
created

T_IDENTIFIER ➔ ... ➔ this.notify   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 1
rs 9.2
c 1
b 0
f 0
cc 4
nc 4
nop 1
1
define(function() {
2
3
    /**
4
     * @class
5
     */
6
    var JsonGeneratorObserver = function() {
7
8
        /**
9
         * @protected
10
         * @type {Object}
11
         */
12
        var $watcher = {};
13
14
15
        /**
16
         * @public
17
         * @param {String} $action
18
         * @param {Function} $callable
19
         */
20
        this.watch = function($action, $callable) {
21
22
            if(!$watcher[$action]) {
23
                $watcher[$action] = [];
24
            }
25
26
            $watcher[$action].push($callable);
27
        };
28
29
30
        /**
31
         * @public
32
         * @param {String} $action
33
         */
34
        this.notify = function($action) {
35
            if($watcher[$action]) {
36
                for(var $i in $watcher[$action]) {
37
                    if($watcher[$action].hasOwnProperty($i)) {
38
                        var $callable = $watcher[$action][$i];
39
40
                        $callable();
41
                    }
42
                }
43
            }
44
        }
45
    };
46
47
    return JsonGeneratorObserver;
48
});